/*
 * sample.h
 *
 *  Created on: 2012-11-10
 *      Author: ssx
 */

#ifndef SAMPLE_H_
#define SAMPLE_H_

#include "../defines.h"

class CSample {
public:
	CSample(unsigned int w,unsigned int h);
	virtual ~CSample();

	virtual void InitSDL();
	virtual void InitOpenGL();
	virtual void MainLoop();
	virtual bool EventLoop();
	virtual void RenderLoop();

	virtual void RenderOnce();

	virtual void OnEventWndResize(int w,int h);
	virtual void OnEventKeyDown(SDLKey iKey);

	bool IsKeyDown(SDLKey iKey);

	virtual Uint32 MyTimer(Uint32 interal,void *param);

	void MyXYZ();
	void MyWireCube(GLfloat w);
	void MySphere(GLdouble radius, GLint slices, GLint stacks);

public:
	unsigned int m_ScreenW;
	unsigned int m_ScreenH;
	GLfloat m_xRot;
	GLfloat m_yRot;

	GLfloat m_xTrans;
	GLfloat m_yTrans;
	GLfloat m_zTrans;
};

class CSp001: public CSample
{
public:
	CSp001(unsigned int w,unsigned int h):CSample(w,h) {};
	virtual void RenderOnce();
};

class CSp002: public CSample
{
public:
	CSp002(unsigned int w,unsigned int h):CSample(w,h) {};
	virtual void InitOpenGL();
	virtual void RenderOnce();
};

class CSp003: public CSample
{
public:
	CSp003(unsigned int w,unsigned int h);
	virtual void InitOpenGL();
	virtual void RenderOnce();
	virtual void OnEventWndResize(int w,int h);
	virtual Uint32 MyTimer(Uint32 interal,void *param);
public:
	GLfloat m_fEarthAngle;
	GLfloat m_fMoonAngle;
};

#define NUM_SPHERES 10
class CSp004: public CSample
{
public:
	CSp004(unsigned int w,unsigned int h):CSample(w,h),m_Rot(0) {};
	virtual void InitOpenGL();
	virtual void RenderOnce();
	void DrawGround();
	virtual void OnEventWndResize(int w,int h);
	virtual void OnEventKeyDown(SDLKey iKey);
public:
	GLFrame m_Spheres[NUM_SPHERES];
	GLFrame m_Camera;
	GLfloat m_Rot;
};


class CSp005: public CSample
{
public:
	CSp005(unsigned int w,unsigned int h):CSample(w,h) {};
	virtual void InitOpenGL();
	void InitPoints();
	virtual void RenderOnce();
	virtual void OnEventWndResize(int w,int h);

public:
	M3DVector3f m_TriPoints[17 * 3];
};


class CSp006: public CSample
{
public:
	CSp006(unsigned int w,unsigned int h);
	virtual void InitOpenGL();
	virtual void RenderLoop();
public:
	GLfloat m_LightPos[4];
};

class CSp007: public CSample
{
public:
	CSp007(unsigned int w,unsigned int h);
	virtual void InitOpenGL();
	virtual void RenderLoop();
	virtual void OnEventWndResize(int w,int h);
	void DrawJet(bool bShadow);
public:
	GLfloat m_LightPos[4];
	M3DMatrix44f m_ShadowMat;
};

extern CSample *pSample;
#endif /* SAMPLE_H_ */
